/*
 * main.cpp
 *
 *  Created on: 2013-2-21
 *      Author: jimline
 */
#include <gtk\gtk.h>
#include <string.h>

void hello(GtkWidget* widget, gpointer data) {
	const gchar* str = gtk_button_get_label(GTK_BUTTON(widget));
	if (0 == strcmp(str, "click me!")) {
	    gtk_button_set_label(GTK_BUTTON(widget), "hello world!");
	}
	else if (0 == strcmp(str, "hello world!")) {
		gtk_button_set_label(GTK_BUTTON(widget), "click me to exit!");
	}
	else {
		gtk_main_quit();
	}
}

void destory(GtkWidget* widget, gpointer data) {
	gtk_main_quit();
}

int main(int argc, char*argv[]) {
	GtkWidget* window;
	GtkWidget* button;
	gtk_init(&argc, &argv);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	button = gtk_button_new_with_label("click me!");
	g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(hello), NULL);
	g_signal_connect(GTK_OBJECT(window), "destory", G_CALLBACK(destory), NULL);
	gtk_container_add(GTK_CONTAINER(window), button);
	gtk_widget_show(button);
	gtk_widget_show(window);
	gtk_main();
	return 0;
}